# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfig do
  @moduledoc """
  Configuration for repricing a Google bill over a period of time.

  ## Attributes

  *   `adjustment` (*type:* `GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingAdjustment.t`, *default:* `nil`) - Required. Information about the adjustment.
  *   `channelPartnerGranularity` (*type:* `GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfigChannelPartnerGranularity.t`, *default:* `nil`) - Applies the repricing configuration at the channel partner level. Only ChannelPartnerRepricingConfig supports this value. Deprecated: This is no longer supported. Use RepricingConfig.entitlement_granularity instead.
  *   `conditionalOverrides` (*type:* `list(GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1ConditionalOverride.t)`, *default:* `nil`) - The conditional overrides to apply for this configuration. If you list multiple overrides, only the first valid override is used. If you don't list any overrides, the API uses the normal adjustment and rebilling basis.
  *   `effectiveInvoiceMonth` (*type:* `GoogleApi.CloudChannel.V1.Model.GoogleTypeDate.t`, *default:* `nil`) - Required. The YearMonth when these adjustments activate. The Day field needs to be "0" since we only accept YearMonth repricing boundaries.
  *   `entitlementGranularity` (*type:* `GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfigEntitlementGranularity.t`, *default:* `nil`) - Applies the repricing configuration at the entitlement level. Note: If a ChannelPartnerRepricingConfig using RepricingConfig.EntitlementGranularity becomes effective, then no existing or future RepricingConfig.ChannelPartnerGranularity will apply to the RepricingConfig.EntitlementGranularity.entitlement. This is the recommended value for both CustomerRepricingConfig and ChannelPartnerRepricingConfig.
  *   `rebillingBasis` (*type:* `String.t`, *default:* `nil`) - Required. The RebillingBasis to use for this bill. Specifies the relative cost based on repricing costs you will apply.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :adjustment =>
            GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingAdjustment.t() | nil,
          :channelPartnerGranularity =>
            GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfigChannelPartnerGranularity.t()
            | nil,
          :conditionalOverrides =>
            list(GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1ConditionalOverride.t())
            | nil,
          :effectiveInvoiceMonth => GoogleApi.CloudChannel.V1.Model.GoogleTypeDate.t() | nil,
          :entitlementGranularity =>
            GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfigEntitlementGranularity.t()
            | nil,
          :rebillingBasis => String.t() | nil
        }

  field(:adjustment, as: GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingAdjustment)

  field(:channelPartnerGranularity,
    as:
      GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfigChannelPartnerGranularity
  )

  field(:conditionalOverrides,
    as: GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1ConditionalOverride,
    type: :list
  )

  field(:effectiveInvoiceMonth, as: GoogleApi.CloudChannel.V1.Model.GoogleTypeDate)

  field(:entitlementGranularity,
    as: GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfigEntitlementGranularity
  )

  field(:rebillingBasis)
end

defimpl Poison.Decoder, for: GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfig do
  def decode(value, options) do
    GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfig.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudChannel.V1.Model.GoogleCloudChannelV1RepricingConfig do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
